<?php

namespace App\Admin\Extensions;

use Encore\Admin\Layout\Row;
use Encore\Admin\Widgets\Box;
use Encore\Admin\Layout\Column;
use App\Services\Statistics\SoftCountCharts;

class DashboardCharts
{
	public function countCharts()
	{
		return function (Row $row) {
			$this->usersIncreasing($row, 4);
			$this->usersConsisting($row, 4);
			$this->profitIncreasing($row, 4);
		};
	}
	
	protected function usersIncreasing(Row $row, $column)
	{
		$row->column($column, function (Column $column) {
			$softCount = app(SoftCountCharts::class)->usersIncrease();
			$column->append(new Box('用户增长', view('admin.home.userIncreasing', ['count' => $softCount])));
		});
	}
	
	protected function usersConsisting(Row $row, $column)
	{
		$row->column($column, function (Column $column) {
			$softCount = app(SoftCountCharts::class)->usersConsist();
			$column->append(new Box('用户组成', view('admin.home.userConsisting', ['count' => $softCount])));
		});
	}
	
	protected function profitIncreasing(Row $row, $column)
	{
		$row->column($column, function (Column $column) {
			$softCount = app(SoftCountCharts::class)->stormRecordsIncrease();
			$column->append(new Box('VIP组成', view('admin.home.vipConsisting', ['count' => $softCount])));
		});
	}
}
